#include <model.h>
#include <modules\terrainModule.h>
#include <modules\fileTextureModule.h>
#include <modules\fileTrajectoryModule.h>
#include <modules\fileTerrainModule.h>
#include <modules\fileTerrainRescaleModule.h>

int main (void) {

  model my_model;

  // check if model is available
  if (!my_model.available("world", "D:\\streamingserverdb\\")) {
    if (!my_model.createModel("world", "D:\\streamingserverdb\\")) return 1;
  }
  
  // open model
  if (!my_model.openModel("world", "D:\\streamingserverdb\\")) return 2;
  
  // elevation data harvested from google using google elevation API
  fileTerrainModule modterrain (
     vec2i(32, 32), 
     vec2i(0, 19),
     -2,
     "data\\prague.xyz"
  );

  //my_model.addModule(&modterrain);
  
  // rescale to coarser recolution the stored elevation data
  fileTerrainRescaleModule modterrainrescale (
     vec2i(32, 32),         // size
     vec2i(282854, 177327), // from
     vec2i(283445, 177919), // to
     vec2i(0, 19),          // levels
     -2,                    // level 0 offse
     0                     // start level
  );

  my_model.addModule(&modterrainrescale);


  // textures harvested from google using app : GMapCatcher
  fileTextureModule modtexture (
    vec2i(256, 256),
    vec2i(0, 19),
    -2,
    "D:\\streamingserverdb\\texture_tiles\\"
  );

  // add textures
  //my_model.addModule(&modtexture);

  // trajectories observed from openstreetmap using java app: josm-tested
  fileTrajectoryModule modtrajectories (
    vec2i(256, 256),
    vec2i(0, 19),
    -2,
    "c:\\Documents and Settings\\jarek\\Dokumenty\\Visual Studio 2005\\Projects\\uplib\\uplib\\praha2.gpx"
  );

  // add trajectories
  //my_model.addModule(&modtrajectories);

  // construct the database using input modules
  my_model.update();

  my_model.addUser("jarek", "uriden0t");

  // finish the model
  my_model.close();

  // return success
  return 0;
}